package com.zhiyou100.advice;

import org.springframework.aop.ThrowsAdvice;

import java.lang.reflect.Method;

/**
 * @author yang
 * @className MyThrowAdvice
 * @packageName com.zhiyou100.advice
 * @Description TODO
 * @date 2020-08-19 14:46
 */
public class MyThrowAdvice implements ThrowsAdvice {


    /**
     * 目标类方法异常时要执行的代码
     *
     * @param method
     * @param args
     * @param target
     * @param ex
     */
    public void afterThrowing(Method method, Object[] args, Object target, Exception ex) {
        System.out.println(method.getName() + " 出现异常了！！！，异常原因是 " + ex.getMessage());
    }
}
